package org.rulix.ogame.player.api;

public class OgamePlanetCoordinates {
	
	//coordinates
	private int galaxy;
	private int solarSystem;
	private int planet;
	
	
	public static OgamePlanetCoordinates getCoordinates(String coordsStr){
		OgamePlanetCoordinates opc = new OgamePlanetCoordinates();
		
		coordsStr = coordsStr.replace("[", "").replace("]", "").trim();
		String[] coords = coordsStr.split(":");
		
		opc.setGalaxy(Integer.valueOf(coords[0]));
		opc.setSolarSystem(Integer.valueOf(coords[1]));
		opc.setPlanet(Integer.valueOf(coords[2]));
		
		return opc;
	}


	public int getGalaxy() {
		return galaxy;
	}


	public void setGalaxy(int galaxy) {
		this.galaxy = galaxy;
	}


	public int getSolarSystem() {
		return solarSystem;
	}


	public void setSolarSystem(int solarSystem) {
		this.solarSystem = solarSystem;
	}


	public int getPlanet() {
		return planet;
	}


	public void setPlanet(int planet) {
		this.planet = planet;
	}
	
	@Override
	public boolean equals(Object obj) {
		OgamePlanetCoordinates opc = null;
		
		if ( obj instanceof OgamePlanetCoordinates )
			opc = (OgamePlanetCoordinates)obj;
		
		
		return (opc.getGalaxy() == getGalaxy() && 
				opc.getSolarSystem() == getSolarSystem() && 
				opc.getPlanet() == getPlanet());
	}

	@Override
	public String toString() {
		return "["+getGalaxy()+":"+getSolarSystem()+":"+getPlanet()+"]";
	}
}
